set more off

eststo clear

foreach dataset in gss ssi {

	use `dataset', clear

	local control income attend male married family_size age hs coll grad white black i.region

	if "`dataset'" != "sccbs" {
		su operational
		replace operational = (operational - r(min)) / (r(max) - r(min))
		gen republicanXoperational = republican*operational
		gen independentXoperational = independent*operational
		eststo: reg ln_totgiv republican independent operational `control'
		eststo: reg ln_totgiv republican republicanXoperational independent independentXoperational operational `control' 
	}

}

label variable operationalconservatism "Operational conservatism"
label variable republicanXoperational "Rep X Operational"
label variable independentXoperational "Ind X Operational"

#delimit;

esttab
	using "table4.tex"
	,
 		order(
			operationalconservatism
			republican
			independent 
			republicanXoperational
			independentXoperational
		)
		replace
 		gap
		compress
		stats(N r2, fmt(%20.00fc %20.02fc) label("Sample size" "R-squared"))
		booktabs
		cells(b(fmt(2) star) se(par))
		label
 		drop(*region*)
		collabels(none)
		width(\textwidth)
		mgroups(
			"GSS" "SSI"
			,
				pattern(1 0 1 0)
				prefix(\multicolumn{@span}{c}{) suffix(})
				span erepeat(\cmidrule(lr){@span})
		)	
		nomtitles
		;

#delimit cr
